package DaEr_5_25;

import java.util.*;

public class DouDiZhu {
    public static void main(String[] args) {
        HashMap<Integer, String> poker = new HashMap<>();
        ArrayList<Integer> pokerIndex = new ArrayList<>();
        //表示花色
        List<String> colors = Arrays.asList("♥","♠","♦","♣");
        //牌面数据
        List<String> numbers = Arrays.asList("2","3","4","5","6","7","8","9","10","J","Q","K","A");

        int index=0;
        poker.put(index,"大王");
        pokerIndex.add(index);
        index++;
        poker.put(index,"小王");
        pokerIndex.add(index);
        index++;

        for (String number:numbers){
            for (String color:colors){
                poker.put(index,color+number);
                pokerIndex.add(index);
                index++;
            }
        }
        System.out.println("poker = " + poker);
        //洗牌
        Collections.shuffle(pokerIndex);

        //发牌
        ArrayList<Integer> player1 = new ArrayList<>();
        ArrayList<Integer> player2 = new ArrayList<>();
        ArrayList<Integer> player3 = new ArrayList<>();
        ArrayList<Integer> dipai = new ArrayList<>();

        for (int i = 0; i < pokerIndex.size(); i++) {
            Integer in = pokerIndex.get(i);
            if (i>=51){
                dipai.add(in);
            }else if (i%3==0){
                player1.add(in);
            }else if (i%3==1){
                player2.add(in);

            }else if (i%3==2){
                player3.add(in);
            }
        }
        Collections.sort(player1);
        Collections.sort(player2);
        Collections.sort(player3);
        Collections.sort(dipai);
        //看牌
        lookpoker("小李",poker,player1);
        lookpoker("小欢",poker,player2);
        lookpoker("小欠",poker,player3);
        lookpoker("底牌",poker,dipai);
    }
    public static void lookpoker(String name,HashMap<Integer,String> poker,ArrayList<Integer> player){
        System.out.println(name+"牌是：");
        for (Integer key:player){
            String s = poker.get(key);
            System.out.print(" " + s);

        }
        System.out.println();
    }

}
